package com.service.impl;

import com.mapper.DingDUserMapper;
import com.pojo.DingDUser;
import com.service.DingDUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 26947
 */
@Service
public class DingDUserServiceImpl implements DingDUserService {
    @Autowired
    private DingDUserMapper dingDUserMapper;

    @Override
    public List<DingDUser> querDDUser() {

  List<DingDUser>   ddUsersList =  dingDUserMapper.querDDUser();
        return ddUsersList;
    }

    @Override
    public String querDDUserNumber(String userName,String DDPassword) {
        if(dingDUserMapper.querDDUserNumber(userName) == null){
            return "账号或密码错误";
        }
      String password=  dingDUserMapper.querDDUserNumber(userName).getUserPassword();
        if(DDPassword.equals(password)){
            return "true";
        }
        return "账号或密码错误";
    }

    @Override
    public String querAdmin(String userName) {
        if(dingDUserMapper.querAddmin(userName) == null){
            return "信息错误";
        }
       int adminInfo =  dingDUserMapper.querAddmin(userName).getUserAdminInfo();
       if(adminInfo == 1){
           return "主管理员";
       }if(adminInfo == 2){
            return "普通员工";
        }
        return "权限信息错误";
    }
    public void ac(){}
}
